package com.jgj.zxkj.lookandcheckjggroupinfo;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.PermissionUtils;
import com.meituan.robust.Patch;
import com.meituan.robust.PatchExecutor;
import com.meituan.robust.RobustCallBack;

import java.util.List;

public class TestActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.screen_test);
        /*PermissionUtils.requestPermissions(this, 100, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                new PermissionUtils.OnPermissionListener() {
                    @Override
                    public void onPermissionGranted() {
                        LogUtils.i("获取读取权限成功");
                    }

                    @Override
                    public void onPermissionDenied(String[] deniedPermissions) {

                    }
                });*/
    }

    public void loadPatch(View v) {
        new PatchExecutor(TestActivity.this, new PatchManipulateImpl()
                , new RobustCallBack() {
            @Override
            public void onPatchListFetched(boolean result, boolean isNet, List<Patch> patches) {
                LogUtils.i("onPatchListFetched:"+result);
            }

            @Override
            public void onPatchFetched(boolean result, boolean isNet, Patch patch) {
                LogUtils.i("onPatchFetched:"+result);
            }

            @Override
            public void onPatchApplied(boolean result, Patch patch) {
                LogUtils.i("onPatchAPplied:"+result);
            }

            @Override
            public void logNotify(String log, String where) {
                LogUtils.i(log);
            }

            @Override
            public void exceptionNotify(Throwable throwable, String where) {
                LogUtils.i(throwable.getMessage());
            }
        }).start();
    }

    public void toRobust(View v) {
        startActivity(new Intent(TestActivity.this, RobustActivity.class));
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        PermissionUtils.onRequestPermissionsResult(this, requestCode, permissions, grantResults);

    }
}
